﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Demonstartor
{
    class InvolvedParametersList: List<InvolvedParameter>
    {
        public InvolvedParametersList()
            : base()
        {

        }

        public InvolvedParametersList(IEnumerable<InvolvedParameter> Params)
            : base(Params)
        {

        }

        public DataTable GetDataTable()
        {
            DataTable Res = new DataTable();

            Res.Columns.Add("Имя");
            Res.Columns.Add("Описание");
            Res.Columns.Add("Причина");

            for (int i = 0; i < Count; i++)
            {
                DataRow R = Res.NewRow();
                R[0] = this[i].Name;
                R[1] = this[i].Description;
                R[2] = this[i].Reason;
                Res.Rows.Add(R);
            }

            return Res;
        }

        public string[] GetNames(bool IncludeDensity = false, bool IncludeBorderLine = false)
        {
            List<string> Res = new List<string>();

            int C = Count;
            for (int i = 0; i < C; i++)
            {
                if ((this[i].Name != "Density") && (this[i].Name != "Border Line"))
                {
                    if (Res.IndexOf(this[i].Name) == -1)
                        Res.Add(this[i].Name);
                }
                else if (IncludeDensity)
                    Res.Add(this[i].Name);
                else if (IncludeBorderLine)
                    Res.Add(this[i].Name);
            }

            return Res.ToArray();            
        }

        public bool HasDensity()
        {
            return IndexOf(InvolvedParameter.Density()) != -1;
        }

        //BorderLine
        public bool HasBorderLine()
        {
            return IndexOf(InvolvedParameter.BorderLine()) != -1;
        }




    }
}
